import { GuideTipsManager } from "../../../manager/GuideTipsManager";
import { Language } from "../../../../../extend/language/Language";
import { AcupointData } from "./AcupointData";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { AcupointBourn } from "./AcupointBourn";
import { AcupointRootTarget } from "./AcupointRootTarget";
import { ObjCreate } from "../../common/ObjCreate";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { LookupPlayerData } from "../LookupPlayerData";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { Cache } from "../../../cache/Cache";
import { AcupointConfig } from "../../../resource/AcupointConfig";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { EffectManager } from "../../../manager/EffectManager";
import { SAcupointInfo } from "../../../../../Message/Game/SAcupointInfo";
type int = number;
//class AcupointButtonPanel
    
    export  class AcupointButtonPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._glowYellow = new Object /* flash.filters.GlowFilter */(16776960, 1, 3, 3, 5);
            this._glowGreen = new Object /* flash.filters.GlowFilter */(65280, 1, 3, 3, 5);
            this._glowblue = new Object /* flash.filters.GlowFilter */(41727, 1, 3, 3, 5);
            this._filterArr = [];
            addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStageHandler);
            this.init();
            return;
        }

        public guideLevelUp(): void
        {
            var loc1=GuideTipsManager.getGuideTips2(GuideTipsManager.Dir_BL, Language.getString(21000));
            loc1.x = this._duButton.x + this._duButton.width;
            loc1.y = this._duButton.y;
            addChild(loc1);
            return;
        }

        public hideGuideLevelUp(): void
        {
            if (GuideTipsManager.guideTips2.parent == this) 
            {
                GuideTipsManager.hideGuideTips2();
            }
            return;
        }

        public dispose(): void
        {
            this._bourn.dispose();
            this._rootTarget.dispose();
            this.hideGuideLevelUp();
            return;
        }

        public set mode(arg1: string)
        {
            this._mode = arg1;
            this._bourn.mode = arg1;
            this._rootTarget.mode = arg1;
            return;
        }

        /* internal  */onAddToStageHandler(arg1: Object /* flash.events.Event */): void
        {
            if (AcupointData.isRootBreakThroughOpen() && this._rootTarget && !this._rootTarget.parent) 
            {
                addChild(this._rootTarget);
            }
            return;
        }

        public get curStep(): int
        {
            return this._curStep;
        }

        /* internal  */init(): void
        {
            this._buttonBg = new Object /* flash.display.Bitmap */();
            this._buttonBg.x = 0;
            this._buttonBg.y = 0;
            addChild(this._buttonBg);
            LoaderHelp.setBitmapdata("AcupointBg.swf", this._buttonBg);
            this._bourn = new AcupointBourn();
            this._bourn.x = 10;
            this._bourn.y = 10;
            addChild(this._bourn);
            this._rootTarget = new AcupointRootTarget();
            this._rootTarget.x = 140;
            this._rootTarget.y = 10;
            if (AcupointData.isRootBreakThroughOpen()) 
            {
                addChild(this._rootTarget);
            }
            this._duButton = ObjCreate.createGButton("", 100, 30, 28, 28, this, "PulseButton");
            this._duButton.textField.filters = [FilterConst.acupointBtnFilter];
            this._renButton = ObjCreate.createGButton("", 67, 73, 28, 28, this, "PulseButton");
            this._renButton.textField.filters = [FilterConst.acupointBtnFilter];
            this._chongButton = ObjCreate.createGButton("", 110, 115, 28, 28, this, "PulseButton");
            this._chongButton.textField.filters = [FilterConst.acupointBtnFilter];
            this._daiButton = ObjCreate.createGButton("", 130, 193, 28, 28, this, "PulseButton");
            this._daiButton.textField.filters = [FilterConst.acupointBtnFilter];
            this._yinweiButton = ObjCreate.createGButton("", 83, 158, 28, 28, this, "PulseButton");
            this._yinweiButton.textField.filters = [FilterConst.acupointBtnFilter];
            this._yangweiButton = ObjCreate.createGButton("", 73, 235, 28, 28, this, "PulseButton");
            this._yangweiButton.textField.filters = [FilterConst.acupointBtnFilter];
            this._yinqiaoButton = ObjCreate.createGButton("", 115, 275, 28, 28, this, "PulseButton");
            this._yinqiaoButton.textField.filters = [FilterConst.acupointBtnFilter];
            this._yangqiaoButton = ObjCreate.createGButton("", 107, 345, 28, 28, this, "PulseButton");
            this._yangqiaoButton.textField.filters = [FilterConst.acupointBtnFilter];
            addEventListener(flash.events.MouseEvent.CLICK, this.onMouseClickHandler);
            return;
        }

        /* internal  */setToolTipDate(): void
        {
            if (this._mode != GModuleEvent.Mode_Self) 
            {
                if (this._mode == GModuleEvent.Mode_Other) 
                {
                    this._info = LookupPlayerData.acupointInfo;
                }
            }
            else 
            {
                this._info = AcupointData.acupointInfo;
            }
            this._duButton.toolTipData = this.getToolTipData(1, this._duButton);
            this._renButton.toolTipData = this.getToolTipData(2, this._renButton);
            this._chongButton.toolTipData = this.getToolTipData(3, this._chongButton);
            this._daiButton.toolTipData = this.getToolTipData(4, this._daiButton);
            this._yinweiButton.toolTipData = this.getToolTipData(5, this._yinweiButton);
            this._yangweiButton.toolTipData = this.getToolTipData(6, this._yangweiButton);
            this._yinqiaoButton.toolTipData = this.getToolTipData(7, this._yinqiaoButton);
            this._yangqiaoButton.toolTipData = this.getToolTipData(8, this._yangqiaoButton);
            return;
        }

        /* internal  */getToolTipData(arg1: int, arg2: GButton): string
        {
            var loc1=0;
            var loc2=0;
            var loc11=null;
            if (this._mode != GModuleEvent.Mode_Self) 
            {
                if (this._mode == GModuleEvent.Mode_Other) 
                {
                    loc1 = LookupPlayerData.lookupData.miniPlayer.career;
                    loc2 = LookupPlayerData.lookupData.miniPlayer.careerEnable;
                }
            }
            else 
            {
                loc1 = Cache.instance.role.careerBasic;
                loc2 = Cache.instance.role.careerEnabled;
            }
            var loc3=AcupointData.getAcupointName(arg1);
            var loc4=AcupointData.getAcupointCurLevel(arg1, this._info);
            var loc5=AcupointData.getAttributesByStep(arg1, 1, this._info.attributes);
            var loc6=AcupointData.getAttributeStr(loc5, "", loc1, loc2, true, true);
            var loc7=AcupointData.getAttributesByStep(arg1, 2, this._info.attributes);
            var loc8=AcupointData.getAttributeStr(loc7, "", loc1, loc2, true, true);
            var loc9=AcupointConfig.instance.getAcuIntroInfoByStep(arg1);
            arg2.label = loc4.toString();
            var loc10=(loc10 = (loc10 = (loc10 = "<textFormat leading=\'2\'>") + "<font color=\'#b1efff\'><p align=\'center\'><font size=\'16\' color=\'#ffff00\'>" + loc3 + "</font></p>\n") + Language.getString(30089) + "： " + loc4 + "\n") + "<font color=\'#ffff00\'>" + loc6 + "</font>\n";
            if (loc4 + 1 <= AcupointData.topLevel) 
            {
                loc10 = (loc10 = loc10 + Language.getString(30090) + "： " + (loc4 + 1) + "\n") + "<font color=\'#ffff00\'>" + loc8 + "</font>";
                if (this._mode == GModuleEvent.Mode_Self && !(arg1 == AcupointData.acupointInfo.step)) 
                {
                    loc11 = AcupointData.getNeedAcupoint(arg1, loc4);
                    loc10 = loc10 + "<font color=\'#ff0000\'>" + Language.getString(30091) + loc11 + "</font>\n\n";
                }
                else if (this._mode == GModuleEvent.Mode_Other && !(arg1 == LookupPlayerData.acupointInfo.step)) 
                {
                    loc11 = AcupointData.getNeedAcupoint(arg1, loc4);
                    loc10 = loc10 + "<font color=\'#ff0000\'>" + Language.getString(30091) + loc11 + "</font>\n\n";
                }
                else 
                {
                    loc10 = loc10 + "\n";
                }
            }
            return loc10 = (loc10 = (loc10 = (loc10 = (loc10 = (loc10 = loc10 + Language.getString(30233) + "\n") + Language.getString(30234) + AcupointData.topLevel + "\n") + Language.getString(30235) + AcupointData.maxRoot + "\n") + "<font color=\'#ffff00\'>" + this.getMaxAttribute(arg1) + "</font>\n\n") + loc9) + "</font></textFormat>";
        }

        /* internal  */getMaxAttribute(arg1: int): string
        {
            var loc1="";
            var loc2=arg1;
            switch (loc2) 
            {
                case 1:
                {
                    loc1 = Language.getString(30025) + " +76363";
                    break;
                }
                case 2:
                {
                    loc1 = Language.getString(30155) + " +7636";
                    break;
                }
                case 3:
                {
                    loc1 = Language.getString(30156) + " +7629";
                    break;
                }
                case 4:
                {
                    loc1 = Language.getString(30236) + " +4545";
                    break;
                }
                case 5:
                {
                    loc1 = Language.getString(30158) + " +3818";
                    break;
                }
                case 6:
                {
                    loc1 = Language.getString(30157) + " +3818";
                    break;
                }
                case 7:
                {
                    loc1 = Language.getString(30159) + " +3818";
                    break;
                }
                case 8:
                {
                    loc1 = Language.getString(30237) + " +3818";
                    break;
                }
            }
            return loc1;
        }

        /* internal  */onMouseClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target as GButton;
            var loc3=loc1;
            switch (loc3) 
            {
                case this._duButton:
                {
                    this._curStep = 1;
                    break;
                }
                case this._renButton:
                {
                    this._curStep = 2;
                    break;
                }
                case this._chongButton:
                {
                    this._curStep = 3;
                    break;
                }
                case this._daiButton:
                {
                    this._curStep = 4;
                    break;
                }
                case this._yinweiButton:
                {
                    this._curStep = 5;
                    break;
                }
                case this._yangweiButton:
                {
                    this._curStep = 6;
                    break;
                }
                case this._yinqiaoButton:
                {
                    this._curStep = 7;
                    break;
                }
                case this._yangqiaoButton:
                {
                    this._curStep = 8;
                    break;
                }
            }
            dispatchEvent(new DataEvent(EventName.CurrentAcupointChange, this._curStep));
            var loc2=[this._glowblue];
            if (this._preTargetBtn != null) 
            {
                EffectManager.glowFilterUnReg(this._preTargetBtn);
            }
            if (!(this._curUpgradeBtn == null) && !(this._curUpgradeBtn == loc1)) 
            {
                this._preTargetBtn = loc1;
                EffectManager.glowFilterReg(loc1, loc2, 0.5, 10, 5, 0);
            }
            AcupointData.selectedStep = this._curStep;
            return;
        }

        public setCurAcupoint(arg1: int): void
        {
            var loc1=null;
            var loc2=0;
            this._curStep = arg1;
            AcupointData.selectedStep = this._curStep;
            dispatchEvent(new DataEvent(EventName.CurrentAcupointChange, this._curStep));
            if (this._preTargetBtn != null) 
            {
                EffectManager.glowFilterUnReg(this._preTargetBtn);
            }
            this.setToolTipDate();
            if (this._mode != GModuleEvent.Mode_Self) 
            {
                if (this._mode == GModuleEvent.Mode_Other) 
                {
                    loc1 = LookupPlayerData.acupointInfo;
                    loc2 = loc1.rootTargetBraekthrough;
                }
            }
            else 
            {
                loc1 = AcupointData.acupointInfo;
                loc2 = AcupointData.curRootTarget;
            }
            this._bourn.updateInfo(loc1.breakThrough);
            this._rootTarget.updateInfo(loc2);
            return;
        }

        public shineButton(arg1: int): void
        {
            var loc2=null;
            var loc1=AcupointData.getAcupointCurLevel(arg1, AcupointData.acupointInfo);
            if (loc1 >= AcupointData.topLevel) 
            {
                return;
            }
            if (this._curUpgradeBtn) 
            {
                EffectManager.glowFilterUnReg(this._curUpgradeBtn);
            }
            this._filterArr.length = 0;
            if (Cache.instance.role.entityInfo.level < 100) 
            {
                if (AcupointData.leftTimes > 0) 
                {
                    this._filterArr = [this._glowYellow];
                }
                else 
                {
                    this._filterArr = [this._glowGreen];
                }
            }
            if (this._filterArr.length != 0) 
            {
                var loc3=arg1;
                switch (loc3) 
                {
                    case 1:
                    {
                        loc2 = this._duButton;
                        break;
                    }
                    case 2:
                    {
                        loc2 = this._renButton;
                        break;
                    }
                    case 3:
                    {
                        loc2 = this._chongButton;
                        break;
                    }
                    case 4:
                    {
                        loc2 = this._daiButton;
                        break;
                    }
                    case 5:
                    {
                        loc2 = this._yinweiButton;
                        break;
                    }
                    case 6:
                    {
                        loc2 = this._yangweiButton;
                        break;
                    }
                    case 7:
                    {
                        loc2 = this._yinqiaoButton;
                        break;
                    }
                    case 8:
                    {
                        loc2 = this._yangqiaoButton;
                        break;
                    }
                    default:
                    {
                        loc2 = null;
                        break;
                    }
                }
                if (loc2) 
                {
                    EffectManager.glowFilterReg(loc2, this._filterArr, 0.5, 10, 5, 0);
                }
                this._curUpgradeBtn = loc2;
            }
            return;
        }

        public updateRootTarget(): void
        {
            if (this._mode == GModuleEvent.Mode_Self) 
            {
                this._rootTarget.updateInfo(AcupointData.curRootTarget);
            }
            return;
        }

        /* internal */ /* var */_glowYellow: Object /* flash.filters.GlowFilter */;

        /* internal */ /* var */_glowGreen: Object /* flash.filters.GlowFilter */;

        /* internal */ /* var */_glowblue: Object /* flash.filters.GlowFilter */;

        /* internal */ /* var */_filterArr: Array<any>;

        /* internal */ /* var */_duButton: GButton;

        /* internal */ /* var */_renButton: GButton;

        /* internal */ /* var */_chongButton: GButton;

        /* internal */ /* var */_daiButton: GButton;

        /* internal */ /* var */_yinweiButton: GButton;

        /* internal */ /* var */_yangweiButton: GButton;

        /* internal */ /* var */_yinqiaoButton: GButton;

        /* internal */ /* var */_yangqiaoButton: GButton;

        /* internal */ /* var */_curStep: int;

        /* internal */ /* var */_curUpgradeBtn: GButton;

        /* internal */ /* var */_preTargetBtn: GButton;

        /* internal */ /* var */_mode: string="自己";

        /* internal */ /* var */_bourn: AcupointBourn;

        /* internal */ /* var */_rootTarget: AcupointRootTarget;

        /* internal */ /* var */_info: SAcupointInfo;

        /* internal */ /* var */_buttonBg: Object /* flash.display.Bitmap */;
    }
